import java.util.HashMap;
import java.util.Map;

//Usage: MDRRMain portNumber ReceiverIP
public class MDRRMain {
	public static void main(String[] args) throws Exception {
		if(args.length != 2)
		{
			System.err.println("Usage: java MDRRMain MDRRPortNo receiverIP(or hostname) ");
			return;
		}
		int portNumber = Integer.parseInt(args[0]);
		
		Map<Integer, Float> policyMap = new HashMap<Integer, Float>();
		policyMap.put(6000, 0.75f);
		policyMap.put(6001, 0.1f);
		policyMap.put(6002, 0.1f);
		
		MDRRBuffer mdrrBuf = new MDRRBuffer(policyMap, 2000);
		MDRRReceiver mdrrRec = new MDRRReceiver(portNumber, mdrrBuf);
		MDRRSender mdrrSender = new MDRRSender(mdrrBuf, args[1]);
		CreditsManager creditsManager = new CreditsManager(mdrrBuf, 5000);
		mdrrRec.start();
		creditsManager.start();
		mdrrSender.start();
	}
}
